﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QingzimaLogicModel;
using Jacaranda.Model;
using QingzimaDB;

namespace QingzimaScenario
{
    public class SongshuiyuanScenario
    {

        public static SongshuiyuanLM HuoquByID(int id)
        {
            return ConvertToLM(Database.SearchOne<SongshuiyuanDB>(new AbstractProperty("ID") == id));
        }

        public static List<SongshuiyuanLM> HuoquModels()
        {
            List<SongshuiyuanLM> tempLMList = new List<SongshuiyuanLM>();
            foreach (SongshuiyuanDB dbModel in Database.All<SongshuiyuanDB>())
            {
                tempLMList.Add(ConvertToLM(dbModel));
            }
            return tempLMList;
        }

        public static void Tianjia(SongshuiyuanLM SongshuiyuanLM)
        {
            SongshuiyuanLM.Save();
        }

        private static SongshuiyuanLM ConvertToLM(SongshuiyuanDB dbModel)
        {
            return dbModel == null ? null : new SongshuiyuanLM(dbModel);
        }

        public static void Shanchu(string key)
        {
            Database.Delete<SongshuiyuanDB>(new AbstractProperty("Key") == key);
        }
    }
}
